﻿using Microsoft.AspNetCore.Mvc;
using PHMEE.Admin.Controllers;
using PHMEE.ToolKits;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace PHMEE.Admin
{
    /// <summary>
    /// 测点管理🚢🌞🌛✨
    /// </summary>
    [Route("phmeeadmin/api/point")]
    public class PointController: PHMEEAdminController
    {
        private readonly IPointAppService pointAppService;

        /// <summary>
        /// 构造器注入
        /// </summary>
        /// <param name="pointAppService"></param>
        public PointController(IPointAppService pointAppService)
        {
            this.pointAppService = pointAppService;
        }

        /// <summary>
        /// 创建测点
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("CreatePoint")]
        public async Task<Guid> CreatePoint(PointCreateDto input)
        {
            return await pointAppService.CreatePointAsync(input);
        }

        /// <summary>
        /// 更新测点
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        [Route("UpdatePoint")]
        public async Task UpdatePoint(PointUpdateDto input)
        {
            await pointAppService.UpdatePointAsync(input);
        }

        /// <summary>
        /// 测点详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPointById")]
        public async Task<PointDto> GetPointById(Guid id)
        {
            return await pointAppService.GetPointByIdAsync(id);
        }

        /// <summary>
        /// 删除测点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        [Route("DeletePoint")]
        public async Task DeletePoint(Guid id)
        {
            await pointAppService.DeletePointAsync(id);
        }

        /// <summary>
        /// 测点分页集合
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPagedPoints")]
        public async Task<PagedResultDto<PointDto>> GetPagedPoints(PointListDto input)
        {
            return await pointAppService.GetPagedPointsAsync(input);
        }

        /// <summary>
        /// 测点分类
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPointCategories")]
        public List<OperationOptionInt> GetPointCategories()
        {
            return pointAppService.GetPointCategories();
        }

        /// <summary>
        /// 测点类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPointTypes")]
        public List<OperationOptionInt> GetPointTypes(PointCategoryEnum pointCategory)
        {
            return pointAppService.GetPointTypes(pointCategory);
        }

        /// <summary>
        /// 测点位置
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPointPositions")]
        public List<OperationOptionInt> GetPointPositions()
        {
            return pointAppService.GetPointPositions();
        }

        /// <summary>
        /// 测点方向
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPointDirections")]
        public List<OperationOptionInt> GetPointDirections()
        {
            return pointAppService.GetPointDirections();
        }

        /// <summary>
        /// 测点算法
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPointDiagnosisAlgs")]
        public List<OperationOptionInt> GetPointDiagnosisAlgs()
        {
            return pointAppService.GetPointDiagnosisAlgs();
        }

        /// <summary>
        /// 测点标签集合
        /// </summary>
        /// <param name="ownerId"></param>
        /// <param name="ownerType"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPointTagOptions")]
        public async Task<List<OperationOptionInt>> GetPointTagOptions(Guid ownerId, string ownerType)
        {
            return await pointAppService.GetPointTagOptions(ownerId, ownerType);
        }
    }
}
